home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 September
/
PCWorld_2006-09_cd.bin
/
v cisle
/
hexer
/
mpth_17.exe
/
{app}
/
scripts
/
customprops.mps
< prev
next >
Wrap
Text File
|
2005-10-24
|
4KB
|
162 lines
include 'def.mps'
include 'gui.mps'
include '*.lng'
option UNDO, 0
option globalvars, 1
call DEC_TEXT_CONV
= display/modify custom file properties
= ensure a current file is available
if currentfile==''
if PARAM_COUNT > 0
!cmd.fileopen PARAMS(0)
else
!cmd.fileopen
endif
if currentfile==''
end
endif
endif
@@dialog
call create_propdlg
call fillprops
GUIShowModal('dlgProperties')
if (GuiExists('dlgItem'))
GuiDestroy('dlgItem')
endif
if (GuiExists('dlgProperties'))
GuiDestroy('dlgProperties')
endif
end
@@fillprops
var fin file
var cp text
fin=fileopen('::current', 'r')
cp = filegetprop(fin, '!'):= return a list of all custom properties
var i dword
guisetprop('dlgProperties.lbprops', 'items', '')
guisetprop('dlgProperties.btnModify', 'enabled', 0)
guisetprop('dlgProperties.btnRemove', 'enabled', 0)
i = textlinecount(cp)
if (i)
var j dword n dword
var s text
j = 0
while j < i
s = textline(cp,j)
n = textpos('=',s)
if (n)
textcut(@s, n+1,1)
endif
guiadditem('dlgProperties.lbprops',s)
inc j, 1
endwhile
endif
fileclose fin
return
@@lbclick
if (guigetprop('dlgProperties.lbprops','itemindex') > -1)
guisetprop('dlgProperties.btnModify', 'enabled', 1)
guisetprop('dlgProperties.btnRemove', 'enabled', 1)
else
guisetprop('dlgProperties.btnModify', 'enabled', 0)
guisetprop('dlgProperties.btnRemove', 'enabled', 0)
endif
return
@@btnRemove_Click
var b_c1 qword
b_c1 = guigetprop('dlgProperties.lbprops','itemindex')
if b_c1 >= 0
var l text s1 text j1 dword i1 dword
i1 = textlinecount(cp)
j1 = 0
l = ''
while j1 < i1
s1 = textline(cp,j1)
if (j1 != b_c1)
l = l+s1+"\n\r"
endif
inc j1, 1
endwhile
fin=fileopen('::current', 'w')
filesetprop fin, '!', l:= set all custom properties
fileclose fin
call fillprops
goto lbclick
endif
return
@@dlgItem_EditChange
var sdiec text sdiec1 text sdiec2 byte
sdiec2 = 1
sdiec = GuiGetProp('dlgItem.edName', 'text')
sdiec1 = GuiGetProp('dlgItem.edValue', 'text')
if (sdiec == '')
sdiec2 = 0
else
if (sdiec1 == '')
sdiec2 = 0
else
if (GuiGetProp('dlgItem.cbNumber', 'Checked'))
if (not isnumber(sdiec1))
sdiec2 = 0
endif
endif
endif
endif
guisetprop('dlgItem.btnOK','Enabled',sdiec2)
return
@@btnAdd_Click
call create_itemdlg
if (GUIShowModal('dlgItem') == IDOK)
var bac1 text bac2 text
bac1 = GuiGetProp('dlgItem.edName', 'text')
bac2 = GuiGetProp('dlgItem.edValue', 'text')
fin=fileopen('::current', 'w')
if (GuiGetProp('dlgItem.cbNumber', 'Checked'))
filesetprop fin, ('!'+bac1), qword(bac2)
else
filesetprop fin, ('!'+bac1), bac2
endif
fileclose fin
call fillprops
endif
return
@@btnModify_Click
call create_itemdlg
s1 = textline(cp, GuiGetProp('dlgProperties.lbprops', 'ItemIndex'))
guisetprop('dlgItem.edName', 'Text', textcut(@s1, 1, textpos('=',s1)-1))
guisetprop('dlgItem.cbNumber', 'Checked', (textcut(@s1, 1, 2) == '=I'))
guisetprop('dlgItem.edValue', 'Text', s1)
guisetprop('dlgItem', 'Caption', __STR_1)
guisetprop('dlgItem.edName', 'ReadOnly', 1)
guisetprop('dlgItem.edName', 'ParentColor', 1)
guisetprop('dlgItem.cbNumber', 'Enabled', 0)
guisetprop('dlgItem.btnOK', 'Enabled', 0)
if (GUIShowModal('dlgItem') == IDOK)
bac1 = GuiGetProp('dlgItem.edName', 'text')
bac2 = GuiGetProp('dlgItem.edValue', 'text')
fin=fileopen('::current', 'w')
if (GuiGetProp('dlgItem.cbNumber', 'Checked'))
filesetprop fin, ('!'+bac1), qword(bac2)
else
filesetprop fin, ('!'+bac1), bac2
endif
fileclose fin
call fillprops
endif
return